import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Card, Table } from 'antd';
import moment from 'moment';

@connect(({ integratedquery, loading }) => ({
  loading: loading.models.integratedquery,
  custConstList: integratedquery.custConstList, // 商务合同列表数据
}))
@Form.create()
class EmpInfor extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {}

  jumpRouting = (targetRouter, contId) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, contId);
  };

  render() {
    const { custConstList, loading } = this.props;
    const columns = [
      {
        title: '合同编号',
        dataIndex: 'contNo',
        onHeaderCell: () => ({
          style: {
            fontWeight: 'bold',
            textAlign: 'left',
          },
        }),
        onCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '合同名称',
        dataIndex: 'contName',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '服务类型',
        dataIndex: 'serTypeName',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '合同状态',
        dataIndex: 'contStateName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
      },
      {
        title: '合同开始日期',
        dataIndex: 'beginDate',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
        render: text => text && moment(text).format('YYYY-MM-DD'),
      },
      {
        title: '创建时间',
        dataIndex: 'creTime',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { textAlign: 'left' } }),
        render: val => val && moment(val).format('YYYY-MM-DD HH:mm'),
      },
      {
        title: '创建人',
        dataIndex: 'creName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
      },
      {
        title: '操作',
        dataIndex: 'operName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
        render: (text, record) => (
          <span
            style={{ color: '#1890FF', cursor: 'pointer' }}
            onClick={() => this.jumpRouting('contId', record.contId)}
          >
            查看
          </span>
        ),
      },
    ];

    return (
      <div>
        <Card
          style={{ marginBottom: 12 }}
          title={<span style={{ fontWeight: 'bolder' }}>商务合同</span>}
          bordered={false}
          id="businesscontract"
        >
          <Table
            rowSelection={null}
            columns={columns}
            dataSource={custConstList && custConstList.list}
            loading={loading}
            rowKey="contId"
            pagination={false}
          />
        </Card>
      </div>
    );
  }
}
export default EmpInfor;
